-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workaround for missing sem_timedwait on os x #80
Conversation
@ghexp, It will cover your contributions to all Microsoft-managed open source projects. |
@ghexp, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that.
Actually, I found a simpler implementation using mach, see http://pastebin.com/pm78BJPi. Turns out mach has semaphore_timedwait. Can we use this instead? |
Found that one too, but appears to be from GPL project Vermont: |
http://pastebin.com/pm78BJPi is just a snippet showing how to use a system call, can you verify this works on OSX, if so, I will switch to using semaphore_timedwait using the mach mach_timespec_t. |
Code sample compiles. If you're switching, note that sem_init / sem_destroy (unnamed semaphore) compiles but is also unsupported at run time on OS X, requiring named semaphores instead sem_open/sem_close. |
Interesting, that stackoverflow also recommends…
https://developer.apple.com/reference/dispatch/1452955-dispatch_semaphore_create
I wonder which one works better on OSX…
|
dispatch_semaphore_create is tied to dispatch queues and tasks which are even less POSIX than the limited support for the standard that OS X already provides. "Because Grand Central Dispatch manages the relationship between the tasks you provide and the threads on which those tasks run, you should generally avoid calling POSIX thread routines from your task code." |
Got it, sounds like we need an implementation of MavLinkSemaphore that works with named semaphores for OSX then…
|
I found yet another set of semaphore classes on OSX: https://developer.apple.com/reference/coreservices/1585569-mpcreatesemaphore So I added code for that, just wish I had a way to test it... See change #4c0df2fe97f692732dd6514b9d696497b95e65d4 |
Follows MIT licensed http://stackoverflow.com/a/37324520
Trying to keep #15 and #36 going